package com.techsoul.module.accounting.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.techsoul.common.core.pojo.vo.UserVo;
import com.techsoul.module.accounting.pojo.param.AccountingApSaveParam;
import com.techsoul.module.accounting.pojo.param.AccountingApSearchParam;
import com.techsoul.module.accounting.pojo.param.MaterialBuyPriceSearchParam;
import com.techsoul.module.accounting.pojo.param.PromotionDiscountPriceSearchParam;
import com.techsoul.module.accounting.pojo.vo.AccountingApViewVo;
import com.techsoul.module.accounting.pojo.vo.AccountingApVo;
import com.techsoul.module.basic.pojo.vo.CustomerVo;
import com.techsoul.module.order.pojo.entity.ReturnOrderItem;
import com.techsoul.module.order.pojo.entity.SalesOrder;
import com.techsoul.module.order.pojo.entity.SalesOrderItem;
import com.techsoul.module.order.pojo.param.SalesOrderItemSaveParam;
import com.techsoul.module.order.pojo.param.SalesOrderItemSearchParam;
import com.techsoul.module.accounting.pojo.vo.AccountingApBrandRateViewVo;
import com.techsoul.module.accounting.pojo.vo.AccountingApSupplierRateViewVo;
import com.techsoul.module.order.pojo.vo.ReturnOrderItemVo;
import com.techsoul.module.order.pojo.vo.SalesOrderItemBrandRateViewVo;
import com.techsoul.module.order.pojo.vo.SalesOrderItemSupplierRateViewVo;
import com.techsoul.module.order.pojo.vo.SalesOrderItemVo;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 财务应付 Service接口
 * 
 * @author liuen
 * @date 2021-04-11
 */
public interface IAccountingApService {

    /**
     * 新增
     * @param params
     * @return
     */
    String insert(AccountingApSaveParam params);

    /**
     * 删除
     * @param id
     * @return
     */
    Integer delete(String id);

    /**
     * 批量删除
     * @param idList
     */
    Integer batchDelete(List<String> idList);

    /**
     * 去重
     */
    void distinct();

    /**
     * 修改
     * @param params
     * @return
     */
    Integer update(AccountingApSaveParam params);

    /**
     * 详情
     * @param id
     * @return
     */
    AccountingApVo findById(String id);

    /**
     * 列表
     * @param params
     * @return
     */
    List<AccountingApVo> findAll(AccountingApSearchParam params);

    /**
     * 列表-分页
     * @param params
     * @param current
     * @param pageSize
     * @return
     */
    IPage<AccountingApVo> findAll(AccountingApSearchParam params, Integer current, Integer pageSize);

    /**
     * 列表-分页
     * @param params
     * @param current
     * @param pageSize
     * @return
     */
    IPage<AccountingApVo> findAllWithRt(AccountingApSearchParam params, Integer current, Integer pageSize);
    /**
     * 报表-分页
     * @param params
     * @param current
     * @param pageSize
     * @return
     */
    IPage<AccountingApVo> settlementViewMonthly(AccountingApSearchParam params, Integer current, Integer pageSize);

    /**
     * 采购报表-分页
     * @param params
     * @param current
     * @param pageSize
     * @return
     */
    IPage<AccountingApVo> settlementViewSkuMonthly(AccountingApSearchParam params, Integer current, Integer pageSize);

    /**
     * 列表字段汇总
     * @param params
     * @return
     */
    AccountingApVo sum(AccountingApSearchParam params);

    /**
     * 退单列表字段汇总
     * @param params
     * @return
     */
    AccountingApVo returnSum(AccountingApSearchParam params);

    /**
     * 报表字段汇总
     * @param params
     * @return
     */
    AccountingApVo settlementViewMonthlySum(AccountingApSearchParam params);
    /**
     * 报表字段汇总
     * @param params
     * @return
     */
    AccountingApVo settlementViewMonthlyReturnSum(AccountingApSearchParam params);

    /**
     * 供应商汇总列表-分页
     * @param params
     *
     * @return
     */
    IPage<AccountingApVo> supplierSumPage(AccountingApSearchParam params, Integer current, Integer pageSize);

    /**
     * 供应商查看 接口
     * @param supplierNo
     * @param dateFrom
     *  @param dateTo
     * @return
     */
    List<AccountingApVo> suppierViewAccount(String supplierNo,String dateFrom,String dateTo);
    /**
     * 获得供应商付款金额
     * @param salesOrderItem
     * @param userVo
     * @return
     */
    String getSupplierApAmount(SalesOrderItemVo  salesOrderItem, UserVo userVo);
    /**
     * 获得供应商付款金额
     * @param salesOrderItem
     * @param userVo
     * @return
     */
     String getCustomerArAmount(SalesOrderItemVo  salesOrderItem,UserVo userVo);
    /**
     * 获得结算数据
     *
     * @param userVo
     * @return
     */
    void generateArAp(UserVo userVo,SalesOrderItemVo salesOrderItemVo);

    /**
     * 获得结算数据
     *
     * @param userVo
     * @return
     */
    void regenerateArAp(UserVo userVo,SalesOrderItemVo salesOrderItemVo);

    void asyncGenerateArAp(UserVo userVo);

    /**
     * 获得结算数据
     *
     * @param userVo
     * @return
     */
    String fixData(UserVo userVo);
    /**
     * 获得结算数据二
     *
     * @param userVo
     * @return
     */
    String fixDataTwo(UserVo userVo);
    String fixDataThree(UserVo userVo);
      String fixDataFour(UserVo userVo);
    /**
     * 获得历史结算数据
     *
     * @param userVo
     * @return
     */
    void generateMigrationArAp(UserVo userVo);

    void asyncGenerateMigrationArAp(UserVo userVo);

    String batchGenerateArAp(List<String> idList,UserVo userVo);

    String batchGenerateHistoricArAp(List<String> idList,UserVo userVo);
    /**
     * 批量生成结算单
     *
     * @param userVo
     * @return
     */
    String batchGenerateArAp(String[] ids, UserVo userVo);

    void genOperationLog(SalesOrderItemVo data, UserVo user );
    /**
     * 获得结算数据
     *
     * @param id
     * @return
     */
    String settleAgain(String id,UserVo sysuser );

    String handleConfirmPay(String id,UserVo sysuser );
    /**
     * 获得单个数据的结算数据
     * @param salesOrderItem
     * @param userVo
     * @return
     */
    String generateSelectedArAp(SalesOrderItemVo salesOrderItem, UserVo userVo);

    /**
     * 产生财务结算数据
     * @param salesOrderItem
     * @param  materialBuyPriceSearchParam
     * @return
     */
    Double getBuyTotalAmount(SalesOrderItemVo salesOrderItem, MaterialBuyPriceSearchParam materialBuyPriceSearchParam);

    /**
     * 产生搞活动财务结算数据
     * @param salesOrderItem
     * @param  promotionDiscountPriceSearchParam
     * @return
     */

    Double getBuyTotalDisctAmount(SalesOrderItemVo salesOrderItem, PromotionDiscountPriceSearchParam promotionDiscountPriceSearchParam,MaterialBuyPriceSearchParam materialBuyPriceSearchParam);
    Double getBuyTotalCuponAmount(SalesOrderItemVo salesOrderItem, PromotionDiscountPriceSearchParam promotionDiscountPriceSearchParam, MaterialBuyPriceSearchParam materialBuyPriceSearchParam) ;
    String editPrice(AccountingApSaveParam params);

    /**
     * 供应商对账减
     *
     * @param  accountingApSaveParam
     * @return
     */
    String handleAdjustSub(AccountingApSaveParam accountingApSaveParam);
    /**
     * 供应商对账减
     *
     * @param  accountingApSaveParam
     * @return
     */
    String handleAdjustAdd(AccountingApSaveParam accountingApSaveParam);
    /**
     * 生成财务应付数据
     * @param apamt
     * @param salesOrderItem
     * @return
     */
     String generateApList(Double apamt,SalesOrderItemVo salesOrderItem,UserVo userVo);
    /**
     * 品牌排行列表-分页
     * @param params
     * @param current
     * @param pageSize
     * @return
     */
    IPage<AccountingApVo> brandRateView(AccountingApSearchParam params, Integer current, Integer pageSize);

    /**
     * 供应商排行列表-分页
     * @param params
     * @param current
     * @param pageSize
     * @return
     */
    IPage<AccountingApVo> supplierRateView(AccountingApSearchParam params, Integer current, Integer pageSize);
    /**
     * sku-分页
     * @param params
     * @param current
     * @param pageSize
     * @return
     */
    IPage<AccountingApViewVo> skuReport(AccountingApSearchParam params, Integer current, Integer pageSize);

    String removeSpecialChar(String input);

    /**
     * 处理退单
     * @param idList
     *
     * @return
     */
    String processReturn(List<String> idList);
    String processReturnAll();
    String reprocessReturn();

    void genOperationLog(ReturnOrderItem data, UserVo user );

    /**
     * 获得地区销售额
     *
     * @return
     */
    AccountingApVo countTodayTotalSale(AccountingApSearchParam accountingApSearchParam);
    String exportData(AccountingApSearchParam params);

    String exportreportData(AccountingApSearchParam params);
    /**
     * 获得地区采购额
     *
     * @return
     */
    AccountingApVo countTotalTodayPurchase(AccountingApSearchParam accountingApSearchParam);
    void genOperationLog(SalesOrderItem data,UserVo user );
    /**
     * 导入订单
     * @param data
     * @return
     */
    SalesOrder importData(String customerNo, SalesOrderItemVo data, String needOrderYn, UserVo user, int itemNo, int line, CustomerVo customerVo, SalesOrder newSalesOrder) ;

    SalesOrder addNewSalesOrder(SalesOrderItemVo salesOrderItemVo, UserVo userVo, CustomerVo customerVo,int line);
    SalesOrderItem addNewItem(SalesOrder newSalesOrder, SalesOrderItemVo data,UserVo userVo,int itemNo,int line);

    SalesOrderItemVo removeSpecialChar(SalesOrderItemVo input);

}
